package com.edu.exam.enums;

/**
 * 监考安排冲突严重程度枚举
 *
 * <p>定义监考安排冲突的严重程度，包括一般、重要、紧急和严重四个级别。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-12
 */
public enum AssignmentConflictSeverity {
    LOW("LOW", "一般"),
    MEDIUM("MEDIUM", "重要"),
    HIGH("HIGH", "紧急"),
    CRITICAL("CRITICAL", "严重");

    private final String code;
    private final String description;

    AssignmentConflictSeverity(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
    /**
     * 根据代码获取枚举值
     *
     * @param code 代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码无效
     */
    public static AssignmentConflictSeverity fromCode(String code) {
        for (AssignmentConflictSeverity severity : AssignmentConflictSeverity.values()) {
            if (severity.code.equals(code)) {
                return severity;
            }
        }
        throw new IllegalArgumentException("Unknown assignment conflict severity code: " + code);
    }

    /**
     * 根据描述获取枚举值
     *
     * @param description 描述
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果描述无效
     */
    public static AssignmentConflictSeverity fromDescription(String description) {
        for (AssignmentConflictSeverity severity : AssignmentConflictSeverity.values()) {
            if (severity.description.equals(description)) {
                return severity;
            }
        }
        throw new IllegalArgumentException("Unknown assignment conflict severity description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}